package com.xjy.headfirst.迭代器.复杂迭代器;

import java.util.Iterator;

/**
 * decription:
 *
 * @author 辛纪元
 * @since 2022-07-15
 */

public class MenuItem extends MenuComponent {

    String name;

    String description;

    /**
     * 素食主义者
     */
    boolean vegetarian;

    double price;

    public MenuItem(String name, String description, boolean vegetarian, double price) {
        this.name = name;
        this.description = description;
        this.vegetarian = vegetarian;
        this.price = price;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public boolean isVegetarian() {
        return vegetarian;
    }

    @Override
    public double getPrice() {
        return price;
    }

    @Override
    public void print() {
        System.out.println(" " + getName() + "," + getPrice() + "  ," + getDescription());
        if (isVegetarian()) {
            System.out.println("V");
        }
    }

    @Override
    public Iterator<MenuComponent> createIterator() {
        return new NullIterator();
    }
}
